<link href="__CDN__/assets/css/frontend{$Think.config.app_debug?'':'.min'}.css?v={$Think.config.site.version|htmlentities}" rel="stylesheet">
<link rel="stylesheet" href="/pc/layui/css/layui.css">
<script src="/pc/js/jquery.min.js"></script>
<script src="/pc/layui/layui.js"></script>
<style>
body{padding:0;}	
</style>
<div class="login-main" style="padding:25px 25px 0;">
	<div id="register-form" class="form-vertical" >
		<!--@IndexRegisterFormBegin-->
		<input type="hidden" name="invite_user_id" value="0" />
		{:token()}
		<div class="form-group">
			<label class="control-label required">{:__('Email')}<span class="text-success"></span></label>
			<div class="controls">
				<input type="text" name="email" id="email" data-rule="required;email" class="form-control"
					placeholder="{:__('Email')}">
				<p class="help-block"></p>
			</div>
		</div>
		<div class="form-group">
			<label class="control-label">{:__('Username')}</label>
			<div class="controls">
				<input type="text" id="username" name="username" data-rule="required;username" class="form-control"
					placeholder="{:__('Username must be 3 to 30 characters')}">
				<p class="help-block"></p>
			</div>
		</div>
		<div class="form-group">
			<label class="control-label">{:__('Password')}</label>
			<div class="controls">
				<input type="password" id="password" name="password" data-rule="required;password" class="form-control"
					placeholder="{:__('Password must be 6 to 30 characters')}">
				<p class="help-block"></p>
			</div>
		</div>
		<div class="form-group">
			<label class="control-label">{:__('Mobile')}</label>
			<div class="controls">
				<input type="text" id="mobile" name="mobile" data-rule="required;mobile" class="form-control"
					placeholder="{:__('Mobile')}">
				<p class="help-block"></p>
			</div>
		</div>

		<!--@CaptchaBegin-->
		{if $captchaType}
		<div class="form-group">
			<label class="control-label">{:__('Captcha')}</label>
			<div class="controls">
				<div class="input-group">
					{include file="common/captcha" event="register" type="$captchaType" /}
				</div>
				<p class="help-block"></p>
			</div>
		</div>
		{/if}
		<!--@CaptchaEnd-->

		<div class="form-group">
			<button type="button" onclick="submit()" class="btn btn-primary btn-lg btn-block">{:__('Sign up')}</button>
			<a href="javascript:void(0);" onclick="go_login()"
				class="btn btn-default btn-lg btn-block mt-3 no-border">{:__('Already have an account? Sign in')}</a>
		</div>
		<!--@IndexRegisterFormEnd-->
	</div>
</div>
<script>
	var layer;
	layui.use(function() {
		layer = layui.layer;
	});
	function go_login(){
		parent.window.show_login();
		//layer.closeAll();
	}
	function submit(){
		$.ajax({
		    type:"POST",
		    url:"/api.php/login/register",
		    dataType:"json",
		    data:{
		        "username":$('#username').val().trim(),
		        "password":$('#password').val().trim(),
		        "email":$('#email').val().trim(),
		        "mobile":$('#mobile').val().trim(),
		        "captcha":$('input[name="captcha"]').val().trim(),
		        "__token__":$('input[name="__token__"]').val().trim(),
		    },
		    success:function(res){
		        console.log(res);
		        if(res.code==0){
		            layer.msg(res.msg,{icon:5});
		            $('input[name="__token__"]').val(res.data.token);
		        }else{
		            layer.msg(res.msg,{icon:6},function(){
		                layer.closeAll();
						parent.location.href="{:url('user/index')}";
		            });
		        }
		    }
		});
	} 
</script>